const mysql = require('mysql2/promise');

async function testConnection() {
    const connection = await mysql.createConnection({
        host: '110.40.137.140',
        port: 3308,
        user: 'xhy_2048',
        password: 'xhy189683',
        database: '2048_test'
    });

    try {
        console.log('正在测试数据库连接...');
        await connection.connect();
        console.log('数据库连接成功！');
        
        // 测试查询
        const [rows] = await connection.query('SELECT 1 + 1 AS result');
        console.log('测试查询结果:', rows[0].result);
        
        // 查看表结构
        console.log('正在查看game_saves表结构...');
        const [columns] = await connection.query('SHOW COLUMNS FROM game_saves');
        console.log('game_saves表结构:', columns);
        
    } catch (error) {
        console.error('数据库连接失败:', error);
    } finally {
        await connection.end();
    }
}

testConnection(); 